package cn.com.jenson.web.log.controller;

import cn.com.jenson.common.BasicController;
import cn.com.jenson.common.ImportVerifierVo;
import cn.com.jenson.common.Result;
import cn.com.jenson.common.SelectVo;
import cn.com.jenson.dao.log.bo.ParkingLogBo;
import cn.com.jenson.dao.log.searchBo.ParkingLogSearchBo;
import cn.com.jenson.dao.log.vo.ParkingLogVo;
import cn.com.jenson.service.log.service.ParkingLogService;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/api/parking_log")
public class ParkingLogController implements BasicController<ParkingLogVo, ParkingLogBo, ParkingLogSearchBo> {

    @Resource
    private ParkingLogService parkingLogService;

    @Override
    public Result<Page<ParkingLogVo>> pageAll(@RequestBody ParkingLogSearchBo parkingLogSearchBo) {
        return Result.suc(parkingLogService.pageAll(parkingLogSearchBo));
    }

    @Override
    public Result<List<ParkingLogVo>> listAll(@RequestBody ParkingLogSearchBo parkingLogSearchBo) {
        return Result.suc(parkingLogService.listAll(parkingLogSearchBo));
    }

    @Override
    public Result<ParkingLogVo> get(@RequestBody ParkingLogSearchBo parkingLogSearchBo) throws InstantiationException, IllegalAccessException {
        return Result.suc(parkingLogService.get(parkingLogSearchBo));
    }

    @Override
    public Result<ParkingLogVo> edit(@RequestBody ParkingLogBo parkingLogBo) throws InstantiationException, IllegalAccessException {
        return null;
    }

    @Override
    public Result<List<ParkingLogVo>> editAll(@RequestBody List<ParkingLogBo> parkingLogBos) {
        return null;
    }

    @Override
    public Result<ParkingLogVo> deleted(@RequestBody ParkingLogSearchBo parkingLogSearchBo) throws InstantiationException, IllegalAccessException {
        return null;
    }

    @Override
    public Result<List<ParkingLogVo>> deletedAll(@RequestBody List<ParkingLogSearchBo> parkingLogSearchBos) throws InstantiationException, IllegalAccessException {
        return null;
    }

    @Override
    public List<ImportVerifierVo> importTemplateVerifiers() {
        return null;
    }

    @Override
    public void importTemplateDownload(HttpServletResponse response) throws IOException {

    }

    @Override
    public Result<List<SelectVo<String, Integer, ParkingLogVo>>> option() {
        return null;
    }

    @PostMapping("/in")
    public Result<String> in(@RequestBody ParkingLogBo parkingLogBo){
        parkingLogService.in(parkingLogBo);
        return Result.suc("ok");
    }

    @PostMapping("/out")
    public Result<String> out(@RequestBody ParkingLogBo parkingLogBo){
        parkingLogService.out(parkingLogBo);
        return Result.suc("ok");
    }
}
